package com.agger.eurekaclientuserservice;

import io.micrometer.core.instrument.MeterRegistry;
import org.dozer.DozerBeanMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

/**
 * @classname: EurekaClientUserServiceApplication
 * @description: Eureka服务提供客户端
 * @author chenhx
 * @date 2020-04-22 10:58:11
 */
@EnableDiscoveryClient                                      // 开启Eureka客户端
@EnableFeignClients(basePackages="com.agger")               // 开启Feign接口扫描
@SpringBootApplication
@MapperScan("com.agger.eurekaclientuserservice.mappers")
public class EurekaClientUserServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaClientUserServiceApplication.class, args);
    }

    /**
     * @Title: dozerBeanMapper
     * @Description: 注入dozer类转换器
     * @param
     * @return org.dozer.Mapper
     * @author chenhx
     * @date 2020-07-22 10:59:45
     */
    @Bean("DozerBeanMapper")
    public DozerBeanMapper dozerBeanMapper(){
        return new DozerBeanMapper();
    }

    /**
     * @Title: configurer
     * @Description: micrometer 用于监控JVM性能指标
     * @param 
     * @return org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer<io.micrometer.core.instrument.MeterRegistry>
     * @author chenhx
     * @date 2020-08-07 10:41:11
     */
    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer( @Value("${spring.application.name}") String applicationName) {
        return (registry) -> registry.config().commonTags("application", applicationName);
    }
}
